#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef struct {
    int *elem;
    int length;
    int stacksize;
} SqList;
void InitList(SqList &L) {
    L.elem = new int [1000];
    L.length = 0;
    L.stacksize = 1000;
}
void Delete(SqList &L, int key) {
    for(int i = 0; i < L.length; i++) {
        if(L.elem[i] == key) {
            for(int j = i; j < L.length; j++)
                L.elem[j] = L.elem[j + 1];
            L.length--;
        }
    }
}
void Load(SqList &L){
    for(int i=0;i<L.length;i++)
        printf("%d ",L.elem[i]);
    printf("\n");
}
int main() {
    int key;
    SqList L;
    InitList(L);
    scanf("%d",&L.length);
    for(int i=0;i<L.length;i++)
        scanf("%d",&L.elem[i]);
    Load(L);
    scanf("%d",&key);
    Delete(L,key);
    Load(L);
    return 0;
}
